package com.codinghero.zqlb.spider.handler;

import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;

import com.codinghero.zqlb.match.MatchUtils;
import com.codinghero.zqlb.match.SoccerMatch;

/**
 * 设置关注的比赛类型，球队
 * 
 * @author liutong01
 * 
 */
public class FocusHandler implements MatchHandler {

	public <T extends SoccerMatch> void handle(List<T> list) {

		Iterator<T> matchIter = list.iterator();
		
		// NEXT_MATCH:
		while(matchIter.hasNext()) {
			SoccerMatch match = matchIter.next();
			
			// （欧冠，亚冠……）
			// 关注的比赛类型
			Entry<String, Integer> e = MatchUtils.contains(
					SoccerMatch.FOCUSED_TYPE_MAP, match.getTypeName());
			if (e != null)
				match.setTypeFocused(1);
			
			// （国安，申花，尤文图斯……）
			// 关注的球队
			e = MatchUtils.contains(
					SoccerMatch.FOCUSED_TEAM_MAP, match.getTeam1Name());
			if (e != null)
				match.setTeam1Focused(1);
			e = MatchUtils.contains(
					SoccerMatch.FOCUSED_TEAM_MAP, match.getTeam2Name());
			if (e != null)
				match.setTeam2Focused(1);
		}
	}

}
